home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #306 (1994)(Rhein-Sieg-Soft).zip / Franz PD Disk #306 (1994)(Rhein-Sieg-Soft).adf / mand2000 / arexx / CustomColourMap.mnd2 < prev    next >
Text File  |  1993-09-26  |  4KB  |  83 lines

  1. /* This script sets up a custom colour mapping, to demonstrate how */
  2. /* you can take complete control of the colour mapping, to get */
  3. /* perfect pictures.  This particular custom colour map is just */
  4. /* an example of the control you can get.  To get good use out of */
  5. /* this feature you will have to carefully adjust the colour map */
  6. /* creation code to fit each particular picture and you will have */
  7. /* to adjust the palette also. */
  8. /* This script is supplied with the Mand2000 demo and release */
  9. /* versions and may be freely distributed. */
  10. /* Copyright 1993 Cygnus Software. */
  11.  
  12. portname = address()    /* Retrieve the current port name. */
  13. /* If the portname does not start with MAND2000 then this script must */
  14. /* have been run with rx, rather than from Mand2000.  Therefore we */
  15. /* need to set the port name.  We do not always set the port name */
  16. /* because it is better to let Mand2000 set it for us, so that */
  17. /* this script can be used with windows other than the one with */
  18. /* port name MAND2000.1. */
  19. if (left(portname, 8) ~= "MAND2000") THEN
  20.     address 'MAND2000.1'
  21.  
  22.  
  23. /* Parse out the command option.  This script is called when the */
  24. /* user wants a custom colour map turned on, when the user wants a custom */
  25. /* colour map turned off, and whenever the number of iterations or other */
  26. /* colourmap settings change. */
  27.  
  28. parse arg command
  29.  
  30. command = upper(command)    /* Make sure the command is in upper case. */
  31.  
  32. if (command = START) then DO
  33.     EVENTACTION COLOURMAPCHANGE CustomColourMap    /* Make sure this script is automatically called. */
  34.     END
  35. else if (command = STOP) then DO
  36.     EVENTACTION COLOURMAPCHANGE    /* Stop this routine from being called anymore. */
  37.     SetColourMap    /* Reset the colour map. */
  38.     Exit
  39.     END
  40.  
  41. getattr stem WindowVar    /* Get the status structure for the window - put it in WindowVar. */
  42.  
  43. address value WindowVar.masterarexx    /* Briefly go to the global ARexx port*/
  44.                     /* - as specified in the window structure. */
  45. getattr stem GlobalVar
  46.  
  47. /* Grab the screen depth and calculate the number of colours from that. */
  48. maxcolour = (2 ** GlobalVar.screendepth) - 1
  49. address    /* Reset to the previous port. */
  50.  
  51. /* Find out the number of iterations. */
  52. maxiters = WindowVar.maxiters
  53.  
  54. /* Because of the enormous amount of time that it takes ARexx to calculate large colour mappings */
  55. /* this code handles a maximum of 1000 iterations.  It would, however, be fairly easy to write a C */
  56. /* program that would calculate a colour map for 30,000 iterations in a fraction of a second.  */
  57. /* This program could then be called from this script, allowing quite quick turn around. */
  58. if maxiters > 1000 THEN DO
  59.     DISPLAYMESSAGE PROMPT "Calculating a colour map with|this many iterations takes|too long.  Calculating a|colour map for 1000 iterations|instead.  Please wait."
  60.     maxiters = 1000
  61.     END
  62. else if maxiters > 500 THEN
  63.     DISPLAYMESSAGE PROMPT "Please wait - calculating a|colour map with this many|iterations will take a moment."
  64.  
  65. colour = 5
  66. ITERARRAY = " "
  67. DO iter = 0 to maxiters by 2
  68.     /* Set the colour bands to alternate between colour four and successive colours. */
  69.     /* If you set maxiterations to 30,000 this will be VERY slow!  ARexx is not a fast */
  70.     /* language. */
  71.     IterArray = IterArray || " " || 4 || " " || colour
  72.     colour = colour + 1
  73.     if (colour > MaxColour) THEN
  74.         colour = 5
  75.     END
  76. /* Tell Mand2000 to use colour 0 for the Mandelbrot set (default is colour 1) and to */
  77. /* use the array of colour numbers we built up in IterArray. */
  78.  
  79. if maxiters > 500 THEN
  80.     DISPLAYMESSAGE OFF
  81.  
  82. SetColourMap 0   IterArray
  83.